package com.wd.live.view.custom

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.view.WindowManager
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.blankj.utilcode.util.ToastUtils
import com.wd.live.R
import com.wd.live.model.bean.LM_QuerylistBean
import com.wd.live.view.adapter.LiveRecyAdapter2

/**
 * 作者：马海钊
 * 时间：2023/8/21 10:25
 * 功能：
 */
var callback:(LM_QuerylistBean)->Unit={}
private var adapter: LiveRecyAdapter2? = null

class CustomDialog_three(context: Context) : Dialog(context) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.dialog_xiao_three)
        initWindow()
        initView()


        callback={

            adapter = context?.let {it1 ->

                it?.let {
//                    if (it.result!=null){
//                        dialog_three_text_num.setText(it.result.size.toString())
//                        dialog_three_shou_num.setText(it.result.size.toString())
//                    }
                    LiveRecyAdapter2(it1,it)
                }
            }

        }


    }
    private fun initView() {
        val shoudao_lianmai_yaoqing = findViewById<ImageView>(R.id.shoudao_lianmai_yaoqing)
        val yaoqing_haoyou_lianmai = findViewById<ImageView>(R.id.yaoqing_haoyou_lianmai)
        val dialog_three_text = findViewById<TextView>(R.id.dialog_three_text)
        val recyid = findViewById<RecyclerView>(R.id.dialog_three_queryrecylist_id)
        val dialog_three_text1 = findViewById<TextView>(R.id.dialog_three_text1)
        val dialog_three_text_num = findViewById<TextView>(R.id.dialog_three_text_num)
        val dialog_three_shou_num = findViewById<TextView>(R.id.dialog_three_shou_num)


        shoudao_lianmai_yaoqing.setOnClickListener {
            shoudao_lianmai_yaoqing.visibility = View.GONE
            yaoqing_haoyou_lianmai.visibility = View.GONE
            dialog_three_text.visibility = View.GONE
            dialog_three_text_num.visibility=View.GONE 
            recyid.visibility = View.VISIBLE
            dialog_three_text1.visibility = View.VISIBLE
            dialog_three_shou_num.visibility = View.VISIBLE


            recyid.layoutManager = LinearLayoutManager(context)
            recyid.adapter = adapter

        }

/*        recyid.layoutManager = LinearLayoutManager(context)
        recyid.adapter = adapter*/
//        yaoqing_haoyou_lianmai.setOnClickListener {
//            ToastUtils.showLong("邀请好友连麦")
//        }
    }
    private fun initWindow() {
        val window = window
        if (window != null) {
            window.setGravity(Gravity.BOTTOM)
            window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))

            //获得window窗口的属性
            val lp = window.attributes
            lp.width = WindowManager.LayoutParams.MATCH_PARENT
            lp.height = WindowManager.LayoutParams.WRAP_CONTENT
            window.attributes = lp
        }
    }


}

